home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / music / cthugha5.zip / CTHU5SRC.ZIP / MOLESTAB.C < prev    next >
C/C++ Source or Header  |  1994-08-19  |  2KB  |  107 lines

  1. //
  2. // Cthugha - Audio Seeded Image Processing
  3. //
  4. // Zaph, Digital Aasvogel Group, Torps Productions 1993-1994
  5. //
  6.  
  7.  
  8. #include <stdio.h>
  9. #include <dos.h>
  10. #include <io.h>
  11. #include <fcntl.h>
  12. #include <stdlib.h>
  13. #include <math.h>
  14. #include <conio.h>
  15.  
  16. #include "cthugha.h"
  17.  
  18. unsigned int map;
  19.  
  20. #define M_PI 3.14159265358979323846
  21. #define RADEG (180.0/M_PI)
  22.  
  23. char *maptabfile="MOLES.TAB";
  24.  
  25. int main(int argc, char **argv)
  26. {
  27.     int x,y,map_x,map_y;
  28.     double polar_r,polar_a;
  29.     double delta_r=2.0,delta_a=0.1;
  30.     double temp_y,temp_x;
  31.     double cent_y,cent_x;
  32.  
  33.     FILE *fp;
  34.  
  35.     argc--; argv++;
  36.     if (argc) {
  37.         delta_r=atof(*argv);
  38.     }
  39.     argc--; argv++;
  40.     if (argc) {
  41.         delta_a=atof(*argv);
  42.     }
  43.  
  44.  
  45.     if ((fp=fopen(maptabfile,"wb"))!=NULL) {
  46.         printf("Writing mapping table: %s\n",maptabfile);
  47.         for (y=0; y<BUFF_HEIGHT; y++) {
  48.             printf("%3d/%3d \r",y+1,BUFF_HEIGHT);
  49.  
  50.             for (x=0; x<BUFF_WIDTH; x++) {
  51.                 if (((x==BUFF_WIDTH/4) && (y==BUFF_HEIGHT/2)) ||
  52.                     ((x==3*BUFF_WIDTH/4) && (y==BUFF_HEIGHT/2))) {
  53.                     map=0;
  54.                 } else {
  55.                     cent_y=BUFF_HEIGHT/2;
  56.                     if (x>BUFF_WIDTH/2) {
  57.                         cent_x=3*BUFF_WIDTH/4;
  58.                         temp_x=abs(x-cent_x);
  59.                     } else {
  60.                         cent_x=BUFF_WIDTH/4;
  61.                         temp_x=abs(x-cent_x);
  62.                     }
  63.                     temp_y=abs(y-cent_y);
  64.  
  65.                     polar_r=sqrt(temp_x*temp_x + temp_y*temp_y);
  66.                     polar_a=atan2((double)(x-cent_x),(double)(y-cent_y));
  67.  
  68.                     polar_r += delta_r;
  69.  
  70.                     if (polar_r<0)
  71.                         polar_r=0.0;
  72.  
  73.                     if (x>BUFF_WIDTH/2) {
  74.                         polar_a += delta_a;
  75.                     } else {
  76.                         polar_a -= delta_a;
  77.                     }
  78.  
  79.                     temp_y=polar_r*(cosl(polar_a));
  80.                     temp_x=polar_r*(sinl(polar_a));
  81.  
  82.                     map_x=temp_x+cent_x;
  83.                     map_y=temp_y+cent_y;
  84.  
  85.                     if ((map_y>=BUFF_HEIGHT) || (map_y<0) ||
  86.                         (map_x>=BUFF_WIDTH) || (map_x<0) ) {
  87.                         map_x=0;
  88.                         map_y=0;
  89.                     }
  90.  
  91.                     map_x=max(map_x,0);
  92.                     map_y=max(map_y,0);
  93.  
  94.                     map=map_y*BUFF_WIDTH+map_x;
  95.  
  96.                 }
  97.                 fwrite(&map,sizeof(int),1,fp);
  98.             }
  99.         }
  100.  
  101.         fclose(fp);
  102.     }
  103.  
  104. }
  105.  
  106.  
  107.